package com.example.model;

import com.example.pages.InternalPage;
import com.example.pages.LoginPage;
import com.example.pages.MyPageFactory;
import com.example.pages.UsersPage;
import org.junit.Before;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.WebDriverWait;
import ru.esteru.selenium.factory.WebDriverFactory;

import java.util.concurrent.TimeUnit;

/**
 * Created with IntelliJ IDEA.
 * User: carapka
 * Date: 04.11.12
 * Time: 14:38
 * To change this template use File | Settings | File Templates.
 */
public class TestBase {
    protected WebDriver driver;
    protected WebDriverWait wait;
    protected String baseUrl;
    protected LoginPage LoginPage;
    protected InternalPage intPage;
    protected UsersPage usersPage;

    @Before
    public void setUp() throws Exception {
        driver = WebDriverFactory.getDriver(DesiredCapabilities.firefox());
        wait = new WebDriverWait(driver, 10);
        baseUrl = "http://localhost:8888/";
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    }

    public LoginPage goToPage(String url) {
        //open main page
        driver.get(baseUrl + url);
        return MyPageFactory.getPage(driver, LoginPage.class);
    }

}
